#include "FileUtils/Data.h"
namespace gengine
{
namespace utils
{


Data*Data::getDataFromFile(const String &fileName)
{
	int fileLen = 0;
    
 
	
	ifstream in(fileName,ios::in|ios::binary);
	
	if(in.is_open() == false)
	{
		cout<<"err";
	}
	in.seekg(0,ios::end);
	
	fileLen = in.tellg();
	
	in.seekg(0,ios::beg);
	
	if(fileLen < 1)
	{
		cout<<"err";
	}
	//if(fileLen<1)
	char *fileData = new char[fileLen+1];

	if(fileData == 0)
	{
		cout<<"err";
		delete []fileData;
	}

	in.read(fileData,fileLen);
	
	in.close();
	
	
	fileData[fileLen] ='\0';
	
	
	Data* data = new Data(fileName,fileData,fileLen);
	
	delete [] fileData;

	return data;
}

const String &Data::getString()
{
	
	
	return fileData;
	
}
Data::~Data()
{
	
}
}
}